package com.cictec.middleware.gps.engine.position.handler;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.cictec.middleware.commons.spring.SpringContextHolder;
import com.cictec.middleware.gps.engine.BusInstance;
import com.cictec.middleware.gps.engine.exception.BusPositionHandlerException;
import com.cictec.middleware.gps.engine.position.BusPositionHandler;
import com.cictec.middleware.gps.engine.position.handler.operateState.OperationStateHandler;

/**
 * 运营状态判断
 * @author ql
 * @date 2017年9月26日
 */
@Component
public class BusPositionOperationHandler implements BusPositionHandler {


	private Logger logger = LoggerFactory.getLogger(BusPositionOperationHandler.class);
	
	@Autowired
	private Map<String, OperationStateHandler> handlers = new HashMap<String, OperationStateHandler>();
	
	@Override
	public void onHandler(BusInstance busInstance) throws BusPositionHandlerException {
		/*
		 * 影响运营状态的业务处理： 运营时间、 强制非运营、包车业务、 调度申请
		 */
		for (Entry<String, OperationStateHandler> handler : handlers.entrySet()) {
			handler.getValue().onHandler(busInstance);
		}
		
		logger.debug("【运营状态】0：【非运营】不在运营时间内 1：【运营】在运营时间内 ===>{}", busInstance.getStatusInOperateTime());
	}

}
